﻿//产品发货操作
var columns =
            [
                { display: 'Key', name: 'ID', type: 'text', hide: 1 },
                { display: 'StockID', name: 'StockID', type: 'text', hide: 1 },
                { display: 'StockCount', name: 'StockCount', type: 'text', hide: 1 },
                { display: 'ProductDeliveryBillID', name: 'ProductDeliveryBillID', type: 'text', hide: 1 },
                { display: '产品类别', name: 'TypeName', mintWidth: 80, width: 120, type: 'text' },
                { display: '产品名称', name: 'ProductName', mintWidth: 80, width: 160, type: 'text' },
                { display: '产品编码', name: 'ProductCode', mintWidth: 80, width: 100, type: 'text' },
                { display: '产品规格', name: 'ProductStandard', mintWidth: 80, width: 200, type: 'text' },
                { display: '出库数量', name: 'SenderCount', mintWidth: 100, width: 140, type: 'int' },
                { display: '包装规格', name: 'Pack', mintWidth: 80, width: 140, editor: { type: 'text'} },
                { display: '客户编号', name: 'ClientNo', mintWidth: 80, width: 140, editor: { type: 'text'} },
                { display: '备注', name: 'Remarks', mintWidth: 80, width: 140 }
             ];

var manager;
//init controls
$(document).ready(function () {
    initligerGrid();
});

function initligerGrid() {
    manager = null;
    manager = $("#ProductDeliveryItemsGrid").ligerGrid({
        columns: columns,
      //  title: '产品发货细',//不能要标题，修改的BUG，不在ligerui.min.js文件中，所以这个BUG还是存在
        showTitle: false,
        width: '100%',
        enabledSort: true,
        enabledEdit: true,
        //height: '99%',
        minHeight:'100px',
        checkbox: false,
        rownumbers: true,
         url: "../ProductDelivery/GetJsonOfBillDetails?billId=" + $("#Id").val() + "&rand=" + Math.random()
    });
}



//收货确认确认 
function audioOperation() {
    var billId = $("#Id").val();
    $.ligerDialog.confirm('入库记录将自动生成，确认并提交？', function (yes) {
        if (yes) {
            if ($("#AffirmState").val() != "1") {
                $.get("../ProductDelivery/Audit?billId=" + billId + "&orgCode=" + $("#HidOrgCode").val(), {}, function (data) {
                    if (data != undefined && data == "9") {
                        $.ligerDialog.success('确认成功!');
                        initligerGrid();
                        ajaxSubmitSuccess();
                    }
                });
            } else {
                $.ligerDialog.success('已确认过，不能重复确认!');
            }
        }
    });
}


//收货确认　打回（确认数量不对，直接打回）
function unAudioOperation() {
    var billId = $("#Id").val();
    $.ligerDialog.confirm('确认要打回该单据吗？', function (yes) {
        if (yes) {
            if ($("#AffirmState").val() != "1") {
                $.get("../ProductDelivery/UnAudit?billId=" + billId + "&orgCode=" + $("#HidOrgCode").val(), {}, function (data) {
                    if (data != undefined && data == "9") {
                        $.ligerDialog.success('打回成功!');
                        initligerGrid();
                        ajaxSubmitSuccess();
                    }
                });
            } else {
                $.ligerDialog.success('订单已确认，不能打回!');
            }
        }
    });
}